package org.com.Controller;


import Entity.Community;
import Entity.Postlike;
import org.com.Service.IPostlikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 277
 * @since 2025-10-04
 */
@RestController
@RequestMapping("/postlike")
public class PostlikeController {
    @Autowired
    private IPostlikeService IPostlikeService;
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @PostMapping("/save")
    public Boolean save(@RequestBody Postlike postlike) {
        return IPostlikeService.save(postlike);
    }

    @PostMapping("/down")
    public Boolean down(@RequestBody Postlike postlike) {
        return IPostlikeService.exsist(postlike);
    }

    @PostMapping("/delete")
    public Boolean delete(@RequestBody Postlike postlike) {
        return IPostlikeService.lambdaUpdate().eq(Postlike::getLikeId, postlike.getLikeId())
                .eq(Postlike::getUserlikeId, postlike.getUserlikeId())
                .remove();
    }
    @PostMapping("/host")
    public List<Community> host(){
//        return IPostlikeService.host();
        return null;
    }
}
